/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
/**
 * $Id: RechargerTypes.hpp,v 1.4 2009-05-13 07:18:18 amaula Exp $
 *
 * \file
 * \brief Example types for a Recharger interface. ___Remember to rewrite this too!!___
 * \author Mikko Elomaa <mikko.elomaa@tkk.fi>
 * \author Antti Maula <antti.maula@tkk.fi>
 *
 */
#ifndef _MACI_RECHARGERTYPES_HPP_
#define _MACI_RECHARGERTYPES_HPP_
#include <inttypes.h>

namespace MaCI {

  /** MaCI - Recharger interface.
   *
   * This namespace contains all the methods and types related
   * to the Recharger interface.
   */
  namespace Recharger {
    
    /** Enumeration types for Recharger data elements.
     */
    enum ERechargerType { 
      KTypeUnknown            = -1, ///  Unkown type.
      KTypeTimestamp          = 1,  ///  Common::TTimestamp element.
      KTypeCommand            = 2,
      KTypeChannel            = 3,
      KTypeStatus             = 4,  ///  TStatus element.
      KTypeVoltage            = 5,  ///  TVoltage element.
      KTypeCurrent            = 6,  ///  TCurrent element.
      KTypeCharge             = 7,  ///  TCharge element.
      KTypeRechargerEvent     = 8   ///  TRechargerEvent element.
    };
    
    
    /** Enumerations for Recharger Command.
     */
    enum ERechargerCommand { 
      KCommandUnknown = 0,
      KCommandQueryStatus = 1,
      KCommandQueryVoltage = 2,
      KCommandSetCurrent  = 3,      //// Set charging current
      KCommandQueryCurrent = 4,
      KCommandSetCharge = 5,       // Set (reset) charge level 
      KCommandQueryCharge = 6      // Get charge level (Ah)

    };


    /** Command.
     *
     * This structure contains command
     * 
     */
    struct TCommand
    {
      TCommand(const unsigned int aCmd = 0) 
	: cmd(aCmd) {}
      uint32_t cmd;       
    };


    /** Channel
     *
     *
     */
    struct TChannel
    {
      TChannel(const unsigned int aChannel = 0) 
	: channel(aChannel) {}
      uint32_t channel;       
    };

    /** Status
     *
     *  Structure for returning status information
     *
     */
    struct TStatus
    {
      TStatus(const unsigned int aStatus = 0) 
	: status(aStatus) {}
      uint32_t status;       
    };



    /** Recharger channel voltage.
     *
     * This structure contains battery voltage of one channel
     * 
     */
    struct TVoltage
    {
      TVoltage(const float aVoltage = 0) 
	: voltage(aVoltage) {}
      float voltage;          /// Battery voltage of the channel
    };


    /** Recharger channel charging current.
     *
     * This structure contains battery voltage of one channel
     * 
     */
    struct TCurrent
    {
      TCurrent(const float aCurrent = 0) 
	: current(aCurrent) {}
      float current;          /// Charging current
    };

   /** Recharger channel charge level.
     *
     * This structure contains battery voltage of one channel
     * 
     */
    struct TCharge
    {
      TCharge(const float aCharge = 0) 
	: charge(aCharge) {}
      float charge;          /// Charge level
    };


    /** Recharger event predefined types.
     */
    enum ERechargerEventType { 
      /** Unknown event type.
       *
       * This event type should never be sent
       * over to remote end.
       */
      KEventTypeUnknown          = 1,
      

      /** Low supply voltage.
       *
       *  The supply voltage of the charger is too low
       */
      KEventTypeLowSupply        = 3,


      /** New battery connected.
       *
       *  A battery is connected to the recharger
       */
      KEventTypeNewBattery       = 4,


      /** Charging done
       *
       * Charging of the battery has finished
       */
      KEventTypeChargingDone     = 2,

      /** Battery disconnected
       *
       * The battery has disconnected from the recharger 
       */
      KEventTypeDisconnected     = 0
    };


    /** Recharger event.
     *
     * This structure contains event data for a Recharger event.
     */
    struct TRechargerEvent {
      TRechargerEvent(const unsigned int aEventType = KEventTypeUnknown,
                      const unsigned int aData = 0)
        : type(aEventType),
          data(aData) {}
      
      uint32_t type;     ///< Event type. See type ERechargerEventType.
      uint32_t data;     ///< Some data.
    };



  }
}

#endif
